//
//  operator_stack.c
//  compilation
//
//  Created by Kevin Le perf on 17/01/12.
//  Copyright (c) 2012 e2co technologie. All rights reserved.
//

#include <stdio.h>
#include "operator_stack.h"
#include "defines.h"

struct operator_stack{
	enum op stack[32]; //last argument = first in this array
	int _count; //number of []
};

struct operator_stack instance_op;

void operator_stack_init(){
	instance_op._count = 0;
}
void operator_stack_push(enum op type){
	instance_op.stack[instance_op._count]=type;
	instance_op._count++;
}
enum op operator_stack_head(){
	return instance_op.stack[instance_op._count-1];
}
enum op operator_stack_pop(){
	enum op t = operator_stack_head();
	instance_op._count--;
	return t;
}

void operator_stack_print(){
	printf("print stack operator\n");
	printf(" > number of elements : %d\n", instance_op._count);
	printf("head to tail\n");
	int i=instance_op._count-1;
	for(; i > -1; i--){
		printf("element i \n");
		operator_print(instance_op.stack[i]);
		printf("\n");
	}
}